<!--
 * @Description: 
 * @Author: ouyaping
 * @Date: 2025-10-07 23:04:21
 * @LastEditors: ouyaping
 * @LastEditTime: 2025-10-07 23:17:29
-->
<template>
    <basic-container>
        <avue-crud :option="option" :data="data" ref="crud" v-model="form" :permission="permissionList" :page="page"
            @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
            @size-change="sizeChange" @on-load="onLoad">
        </avue-crud>
    </basic-container>
</template>

<script>
import { getDeviceLogs } from "@/api/logs";
import { mapGetters } from "vuex";

export default {
    data () {
        return {
            form: {},
            selectionList: [],
            query: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0
            },
            option: {
                height: 'auto',
                calcHeight: 210,
                searchShow: true,
                searchMenuSpan: 6,
                tip: false,
                border: true,
                index: true,
                viewBtn: false,
                editBtn: false,
                addBtn: false,
                delBtn: false,
                menuWidth: 120,
                dialogType: 'drawer',
                column: [
                    {
                        label: "操作时间",
                        prop: "createTime",
                        // search: true
                    },
                    {
                        label: "操作用户",
                        // prop: "serverHost",
                        // search: true
                    },
                    {
                        label: "ip地址",
                        prop: "serverIp"
                    },
                    {
                        label: "功能",
                        // prop: "env"
                    }
                ]
            },
            data: []
        };
    },
    computed: {
        ...mapGetters(["permission"]),
        permissionList () {
            return {
                viewBtn: this.validData(this.permission.devicecommandlog_view, false)
            };
        }
    },
    methods: {
        searchReset () {
            this.query = {};
            this.onLoad(this.page);
        },
        searchChange (params, done) {
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        currentChange (currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange (pageSize) {
            this.page.pageSize = pageSize;
        },
        onLoad (page, params = {}) {
            getDeviceLogs(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;
            });
        }
    }
};
</script>

<style></style>
